{extend name="base_mobile" /}
{block name="body"}
<header class="hui-header">
    <div id="hui-back"></div>
    <h1>编辑跟踪记录</h1>
</header>
<div class="hui-wrap">
    <form action="{:request()->url()}" class="hui-form" method="post">
        {foreach name="config" item="config"}
        <div class="hui-form-items">
            <div class="hui-form-items-title">{$config.title}</div>
            {if $config.type eq 'input'}
            <input type="text" name="{$config.name}" value="{if isset($data.jdata[$config.name])}{$data.jdata[$config.name]}{else}{$config.value|default=''}{/if}" autocomplete="off" class="hui-input hui-input-clear">
            {/if}
            {if $config.type eq 'textarea'}
            <div class="hui-form-textarea">
                <textarea name="{$config.name}" placeholder="请输入{$config.title}">{if isset($data.jdata[$config.name])}{$data.jdata[$config.name]}{else}{$config.value|default=''}{/if}</textarea>
            </div>
            {/if}
            {if $config.type eq 'select'}
            {if $config.is_sys eq '1'}
            <div class="hui-form-select">
                <select name="{$config.name}">
                    {foreach name=":parse_attr($config.options)" key="i" item="j"}
                    <option value="{$i}" {if condition="$data[$config.name] eq $i"}selected="selected"{/if}>{$j}</option>
                    {/foreach}
                </select>
            </div>
            {else}
            <div class="hui-form-select">
                <select name="{$config.name}">
                    {foreach name=":parse_attr($config.options)" key="i" item="j"}
                    <option value="{$i}" {if condition="isset($data.jdata[$config.name]) eq $i"}selected="selected"{/if}>{$j}</option>
                    {/foreach}
                </select>
            </div>
            {/if}
            {/if}
            {if $config.type eq 'radio'}
            {foreach name=":parse_attr($config.options)" key="i" item="j"}
            <div class="hui-form-radios" style="line-height:38px;">
                <input type="radio" name="{$config.name}" value="{$i}" title="{$j}" {if condition="isset($data.jdata[$config.name]) eq $i"}checked="checked"{/if}>
            </div>
            {/foreach}
            {/if}
            {if $config.type eq 'image'}
            <input type="text" name="{$config.name}" value="{if isset($data.jdata[$config.name])}{$data.jdata[$config.name]}{else}{$config.value|default=''}{/if}" autocomplete="off" placeholder="请上传{$config.title}" class="hui-input">
            <button type="button" class="hui-btn hui-btn-primary hui-btn-position ajax-images"><i class="fa fa-file-image-o"></i> 选择图片</button>
            {/if}
            {if $config.is_sys eq '1'}
            <div class="hui-form-mid hui-word-aux"><a class="hui-button hui-button-small hui-fl" href="{:url('user/config/index')}">设置参数值</a></div>
            {/if}
        </div>
        {/foreach}
        <div class="hui-form-items">
            <div class="hui-form-items-title">备注</div>
            <div class="hui-form-textarea">
                <textarea name="remark" class="layui-textarea">{$data.remark|default=''}</textarea>
            </div>
        </div>
        <hr>
        <div class="hui-form-items">
            <div class="hui-form-items-title">客户信息</div>
            <input type="checkbox" name="update_customer" id="c1" onchange="showCheckRes(this);" /><label for="c1">同步修改客户基本信息</label>
        </div>
        <div id="myid">
            {foreach name="config_customer" item="config"}
            <div class="hui-form-items">
                <div class="hui-form-items-title">{$config.title}</div>
                <div class="hui-form-select">
                    {if $config.type eq 'select'}
                    <select name="customer[{$config.name}]">
                        {foreach name=":parse_attr($config.options)" key="i" item="j"}
                        <option value="{$i}" {if condition="$customer[$config.name] eq $i"}selected="selected"{/if}>{$j}</option>
                        {/foreach}
                    </select>
                    {/if}
                </div>
            </div>
            {/foreach}
        </div>
        <div style="padding:15px 8px;">
            <button class="hui-button hui-button-large hui-primary" lay-filter="*" lay-submit="">保存</button>
        </div>
    </form>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
    $("#myid").hide();
    function showCheckRes(_selfBtn){
        var vals = new Array();
        hui(_selfBtn).parent().find('input').each(function(cObj){
            if(cObj.checked){
                vals.push(cObj.value);
            }
        });
        //console.log(vals);
        if(vals=='on'){
            $("#myid").show();
        }else{
            $("#myid").hide();
        }
    }
    
</script>
{/block}